<script>
_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
if(h<_rate*1206){
	 h=_rate*1206;
}
document.body.addEventListener('touchmove', function(e) {e.preventDefault();}, { passive: false }); 
$('html,body').css({overflow:'hidden',height:'100%',position:'fixed',left:0,top:0});
var _videoA= document.getElementById("thev1");
$(function(){
  
	$('.container').width(sWidth).height(h);
 
    $('.p1-t1').css({"top":_rate*6});
    $('.p1-t2').css({"top":_rate*138});
    $('.p1-t4').css({"top":_rate*80});
   
    $('.p1-t3').css({"top":_rate*1206});
    $('.arr').width(_rate*58).height(_rate*54).css({"left":_rate*346,'bottom':'2.6%'});
 
    $('.p2-t2').css({"top":_rate*1060});
    $('.p2-z1').css({"top":-_rate*34});
    $('.p2-z2').css({"top":_rate*819});
    

    $('.thekv').height(_rate*422).css({"top":_rate*410, "left":0});
    $('.thevideo').width(sWidth).height(_rate*422).css({"top":0, "left":0});

    $('.p3-form').css({"top":_rate*401});
     
    $('.p3-t2').css({"top":_rate*200});
    $('.p3-t3').css({"top":0});
    
    $('.p3-sheng').height(_rate*90).css({'top':_rate*212, 'line-height':_rate*90+'px'});
    $('.p3-name').height(_rate*90).css({'top':_rate*420, 'line-height':_rate*90+'px'});
    $('.p3-phone').height(_rate*90).css({'top':_rate*628, 'line-height':_rate*90+'px'});
    
    $('.p3-btn').width(_rate*370).height(_rate*150).css({"top":_rate*750, "left":_rate*200});

    $('.p4-t1').css({"top":_rate*80});
    $('.p4-z1').css({"top":_rate*320});
    $('.p4-t2').css({"top":_rate*550});
    $('.p4-t3').css({"top":_rate*1000});

   
    $(".p1").css({"opacity":1}).fadeIn();
    $('.p1-s1').width(sWidth).height(h);

    if(h < _rate*1450){
      $('.p4-t1').css({"top":_rate*50})
      $('.p4-z1').css({"top":_rate*280});
      $('.p4-t2').css({"top":_rate*510});
      $('.p4-t3').css({"top":_rate*960});
      $('.p4-b').css({"bottom":0})
      
      
    }

    if(h > _rate*1463){
      $('.p2-z1').css({"top":0});
      $(".p2-z2").attr("src","<?php echo $cdnUrl ?>img/p2-z2-2.jpg");
      $('.thekv').css({"top":_rate*442});
    } 

    if(h < _rate*1208){
       var _cha=h - _rate*1400;
       $('.p1-b').css({"top":-_rate*80});
      
       $('.p1-t1, .p1-t2, .p1-t3').addClass("ip6-p");
       $('.p1-t1').css({"top":0});
       $('.p1-t2').css({"top":_rate*80});
       $('.p1-t3').css({"top":_rate*1036});
       $('.p2-t2, .p3-t2').addClass("ip6-p");
       $('.p2-t2').css({"top":_rate*960});
       $('.p3-t2').css({"top":_rate*140});
       $('.p3-form').css({"top":_rate*240});

       $('.p4-t1').css({"top":_rate*10})
       $('.p4-z1').css({"top":_rate*200});
       $('.p4-t2').css({"top":_rate*310});
       $('.p4-t3').css({"top":_rate*740});
    }

    if(h > _rate*1468){
         
        $(".p1-b").attr("src","<?php echo $cdnUrl ?>img/p1-b-x.jpg");
        $(".p3-b, .p4-b").attr("src","<?php echo $cdnUrl ?>img/p3-b-x.jpg");
        $('.p1-t3').css({"top":_rate*1276}); 

        $(".p2-z2").attr("src","<?php echo $cdnUrl ?>img/p2-z2-2.jpg");
        
    }

    //$(".p1").hide();
   // $(".p4").show();

    var _s1 = new Swiper('.p1-s1', {
		   initialSlide:0,
		   direction : 'vertical',
		   speed:260,
           observer: true,//修改swiper自己或子元素时，自动初始化swiper
           observeParents: true,//修改swiper的父元素时，自动初始化swiper
		   on: {
		    init: function(swiper){
                  $(".swiper-slide-next .animated, .swiper-slide-prev .animated").hide();
                  
		    },
        slideChangeTransitionEnd: function(){
              _videoA.pause();
             //$("#thev1").hide();
              //$(".vide-kv").fadeIn();
               $(".swiper-slide-next .animated, .swiper-slide-prev .animated").hide();
               $(".swiper-slide-active .animated").show();
		           $(".arr").hide();
               window.setTimeout(function(){
                    $(".swiper-slide-active .arr").show();
               }, 900);
              _hmt.push(['_trackEvent', 'p'+_s1.activeIndex, 'click', '页面'+_s1.activeIndex]);   
		    } 
		   } 
 
		    });

     function setAni(){
      console.log(_s1.activeIndex);
        if(0 == _s1.activeIndex){
            _s1.allowSlidePrev= false;
        }else{
           _s1.allowSlidePrev=true;
        }
        if(2 == _s1.activeIndex){
            _s1.allowSlideNext= false;
        }else{
           _s1.allowSlideNext=true;
        }
        window.setTimeout(function(){
            setAni();
        }, 700);
    }
    setAni();
    
     
    var _isPlay=false;
	$(".vide-kv").click(function(){
	  if(true == _isPlay){return;}
	  _isPlay=true;
	  $(".vide-kv").fadeOut();
	  $("#thev1").show();
	  _videoA.currentTime =0;
      _videoA.play();
      window.setTimeout(function(){
    	  _isPlay=false;
          }, 200);
	});
  $(".thekv").click(function(){
     _hmt.push(['_trackEvent', 'video', 'click', '播放']);  
  });
	window.setTimeout(function(){
	  _videoA.addEventListener('ended',function(){
		  //  $("#thev1").hide();
	     // $(".vide-kv").fadeIn();
      });
	}, 400);

    



var _province='';
var _cityData=[];
for (var i=0;i<cityData.length;i++) {
     cityData[i].value=cityData[i].label;
}
 
 var depth=1;
$(".p3-sheng").click(function(){

	weui.picker(cityData, {
		depth: depth,
		className: 'picker',
		defaultValue: ['北京'],
		onChange: function (result) {
		  // console.log(result);
		},
		onConfirm: function (result) {
		   console.log('result: ', result);
		   console.log(result[0].label);
		  _province=result[0].label;
		  $(".p3-sheng").html(_province);
		  if('' == _province){
		  	$(".p3-sheng").addClass("sheng-empty");
		  }else{
		  	 $(".p3-sheng").removeClass("sheng-empty");
		  }
		   
		},
		id: 'shengPick'
		});
});

         
$('.p3-btn').click(function(){
	var _sheng=_province;
	var _name=$("#p3name").val();
	var _phone=$("#p3phone").val();
    if ('' == _sheng) {
    	_popMsg("请输入省份");
        return;
    }
    if ('' == _name) {
    	_popMsg("请输入姓名");
        return;
    }
    if ('' == _phone) {
    	_popMsg("请输入手机号");
        return;
    }
    if (_phone.substr(0,1) == _phone.substr(1,1) && _phone.substr(0,1) == _phone.substr(2,1)) {
    	_popMsg("请输入正确手机号");
        return;
    }
    if (false == /^\d+$/.test(_phone) || _phone.length < 11) {
    	_popMsg("请输入正确手机号");
        return;
    }
    
    $.post("api/?c=setu", {sheng:_sheng,name:_name,phone:_phone}, function(data){
        $(".p4-z1").html('亲爱的'+_name+'，邀您见证');
     	  $(".p1").hide();
        $(".p4").fadeIn(); 
         _hmt.push(['_trackEvent', 'p3yq', 'click', '生成邀请函']);  
          _hmt.push(['_trackEvent', 'p4', 'view', '结果页']); 
    }, "json");
    
    

});

function _popMsg(msg){
	$(".weui-msg").html(msg);
    $(".js_dialog").show();
}
$(".weui-btn").click(function(){
    $(".js_dialog").hide();
});


wx.config({
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'showMenuItems', 'hideMenuItems']
    });
    var _title='悠莱15周年时光盛典直播邀请函';
    var _desc='8月12日 19:15 陪你不负时光不负自己';
    var _link='http://urara-yqh.mei94.com/';
    var _imgUrl='http://urara-yqh.mei94.com/img/64.jpg';
      wx.ready(function () {
        wx.updateAppMessageShareData({
            title: _title, 
            desc: _desc, 
            link: _link, 
            imgUrl: _imgUrl,success: function () {}
          });
         wx.updateTimelineShareData({
                title: _desc, 
                link: _link, 
                imgUrl: _imgUrl, success: function () {}});
      });




       
      
});
</script>